<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use DB;

class PicController extends Controller
{
    public function doUpload(Request $request)
    {
    	if ($request->hasFile('mypic')) {
    		if ($request->file('mypic')->isValid()) {
			    $file = $request->file('mypic');
			    $ext = $file->getClientOriginalExtension();
			    $picname = time().rand(1000,9999).'.'.$ext;
			    $file->move('./uploads/',$picname);
			    if($file->getError()>0){
			    	echo '上传失败';
			    }else{
			    	$data=array('pic'=>$picname);
			    	DB::table("goods")->where('pic',NULL)->update($data);
			    	return view("admin.goods.bigpic");
			    }
			}
		}
    }
}
